Average hourly salinity
Data at Fort Point and EOS are collected every 6 minutes, data at China Camp and Richardson Bay is collected every 15 minutes. I’m going to convert all data to average hourly (60min) salinity so that everything is consitent. The outliers were removed before this step. Outliers detected by QC flag and +/- 2sd from 7 day rolling mean. Using averageTime function in openair package to calculate hourly salinity mean.
Eos
For timeAverage function to work, you need a date or POSIXct column named “date”. interval = frequency of data collection.
eos<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/eos_sal_clean.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
eos<-subset(eos, select=c(datetime, salinity))
names(eos)[names(eos) == "datetime"] <- "date"
eos$date<-as.POSIXct(eos$date, format = c("%Y-%m-%dT%H:%M:%SZ"))
eos_h_sal<- timeAverage(eos,
avg.time="1 hour",
data.thresh = 0,
statistic = "mean",
interval = "6 min",
remove.calm = FALSE,
type = "default")
## Warning in checkPrep(mydata, vars, type = "default", remove.calm = FALSE, :
## Detected data with Daylight Saving Time, converting to UTC/GMT
eos_g<-eos_h_sal %>% ggplot(aes(x=date, y=salinity, color=salinity))+
geom_point(alpha=0.5)+ylim(0,35)+
labs(title="Hourly salinity from EOS resesarch pier",
subtitle="01/01/2017 - 12/31/2019",
caption= "data courtesy of CeNCOOS")
Richardson Bay
rb<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/rb_sal_clean.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
rb<-subset(rb, select=c(DateTimeStamp, Sal))
names(rb)[names(rb) == "DateTimeStamp"] <- "date"
rb$date<-as.POSIXct(rb$date, format = c("%m/%d/%y %H:%M"))
rb_h_sal<- timeAverage(rb,
avg.time="1 hour",
data.thresh = 0,
statistic = "mean",
interval = "15 min",
remove.calm = FALSE,
type = "default")
## Warning: Missing dates detected, removing 12 lines
## Warning in checkPrep(mydata, vars, type = "default", remove.calm = FALSE, :
## Detected data with Daylight Saving Time, converting to UTC/GMT
rb_g<-rb_h_sal %>% ggplot(aes(x=date, y=Sal, color=Sal))+
geom_point(alpha=0.5)+ylim(0,35)+
labs(title="Hourly salinity from Richardson Bay",
subtitle="01/01/2017 - 12/31/2019",
caption= "data courtesy of NERR")
Fort Point
fp<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/fp_sal_clean.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
fp<-subset(fp, select=c(datetime, sea_water_practical_salinity))
names(fp)[names(fp) == "datetime"] <- "date"
fp$date<-as.POSIXct(fp$date, format = c("%Y-%m-%dT%H:%M:%SZ"))
fp_h_sal<- timeAverage(fp,
avg.time="1 hour",
data.thresh = 0,
statistic = "mean",
interval = "6 min",
remove.calm = FALSE,
type = "default")
## Warning: Missing dates detected, removing 30 lines
## Warning in checkPrep(mydata, vars, type = "default", remove.calm = FALSE, :
## Detected data with Daylight Saving Time, converting to UTC/GMT
write.csv(fp_h_sal, "C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/fp_hourly_sal.csv")
fp_g<-fp_h_sal %>% ggplot(aes(x=date, y=sea_water_practical_salinity, color=sea_water_practical_salinity))+
geom_point(alpha=0.5)+ylim(0,35)+
labs(title="Hourly salinity from Fort Point",
subtitle="01/01/2017 - 12/31/2019",
caption= "data courtesy of CeNCOOS")
China Camp
cc<-read.csv("C:/Users/chels/Box Sync/Thesis/Data/Working data/Bouy data/cc_sal_clean.csv", header = TRUE, sep=",", fileEncoding="UTF-8-BOM", stringsAsFactors = FALSE)
cc<-subset(cc, select=c(DateTimeStamp, Sal))
names(cc)[names(cc) == "DateTimeStamp"] <- "date"
cc$date<-as.POSIXct(cc$date, format = c("%m/%d/%Y %H:%M"))
cc_h_sal<- timeAverage(cc,
avg.time="1 hour",
data.thresh = 0,
statistic = "mean",
interval = "15 min",
remove.calm = FALSE,
type = "default")
## Warning: Missing dates detected, removing 12 lines
## Warning in checkPrep(mydata, vars, type = "default", remove.calm = FALSE, :
## Detected data with Daylight Saving Time, converting to UTC/GMT
cc_g<-cc_h_sal %>% ggplot(aes(x=date, y=Sal, color=Sal))+
geom_point(alpha=0.5)+ylim(0,35)+
labs(title="Hourly salinity from China Camp",
subtitle="01/01/2017 - 12/31/2019",
caption= "data courtesy of NERR")
All together
ggarrange(cc_g, eos_g, rb_g, fp_g, nrow=4, ncol=1)
## Warning: Removed 1270 rows containing missing values (geom_point).
## Warning: Removed 819 rows containing missing values (geom_point).
## Warning: Removed 3114 rows containing missing values (geom_point).
## Warning: Removed 3661 rows containing missing values (geom_point).